<html><head>
  <meta charset="utf-8">
   <#assign base=request.contextPath  />
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>月子餐单</title>
  <link rel="stylesheet" href="${base}/js/layui/css/layui.css" media="all">
  <script type="text/javascript" src="${base}/js/zhang.js"></script>
<style type="text/css">
  	.tk9{    

			   margin: 0;
			    border: solid 2px #1E9FFF;
			    position: absolute;
			    left: 30%;
			    bottom: 30%;
			    background: white;
			    line-height: 40px;
			    margin-left: 10px;
			    display: none;
			    font-size:16px;
			}
 </style>
</head>

<body>
 <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>月子餐单</legend>
</fieldset>
<div >
	<button class="layui-btn layui-btn-warm btnjs9" type="button"style="background-color:#1E9FFF;" >月子餐单周期</button>
</div>
<table class="layui-hide" id="table_huli" lay-filter="user"></table> 
<div class="tk9">
				<div  style="height: 40px;background-color:#1E9FFF;text-align: center;color: white;" >
			      月子餐单
				</div>
	    <form  action="" method="get" style="padding: 5px;">
	      <div id="tankuang2" style="margin-left: 20px;">
		       	<div class="layui-inline">
					        菜品:<select  name="vegetable" lay-verify="required" lay-search="" id="vegetable"  > </select><br/>
						    房间:<select name="modules" lay-verify="required" lay-search="" id="home_id"><option value="">直接选择或搜索选择</option></select><br/>
					        周期:<select name="modules"  id="cycle" lay-verify="required" lay-search="" ><option value="">直接选择或搜索选择</option></select><br/>
							食用时间:<input id="test5" placeholder="yyyy-MM-dd HH:mm:ss" type="text">
				</div>
		 </div>
	         <div style="text-align: center">
				<button class="layui-btn layui-btn-warm" type="button" onclick="foodsubmit()" style="background-color:#1E9FFF;" >提交</button>
				<input style="background-color:#1E9FFF;" type="button" value="取消" class="layui-btn layui-btn-warm" onclick="javaScript:window.location.reload();"></input>
			 </div>
		</form>
</div>

<script src="${base}/js/layui/layui.js" charset="utf-8"></script>
<script src="${base}/js/jquery.min.js"></script>
<script>
	$(".btnjs9").click(function(){
			$(".tk9").show(200)
			})
layui.use(['element','table','laydate'], function(){
    var laydate = layui.laydate;
	var table = layui.table;
  var $ = layui.jquery;
 var element = layui.element;
   table.render({
    elem: '#table_huli'
    ,url: '${base}/foodRelation/selectFoodRelation'//数据接口
    ,toolbar: '#toolbarDemo'
    ,defaultToolbar: ['filter', 'print', 'exports']
    ,cols: [[
      {field:'foodNmae', title: '菜品',align:'center'}
      ,{field:'room_name', title: '房间', align:'center'}
      ,{field:'name', title: '周期', align:'center'}
      ,{field:'eachTime', title: '食用时间',templet:function(val){
                                                  return changeDateFormat(val.eachTime);
                                                   },align:'center'}
 ]]
    ,id: 'testReload'
    ,page: true
  });
    laydate.render({
      elem: '#test5'
      ,type: 'datetime'
    });
});
function foodsubmit(){
 var cycle = $("#cycle").val();
 var vegetable  = $("#vegetable").val();
   var home_id  = $("#home_id").val();
   var create_id  = $("#test5").val();
      $.ajax({
         type : "POST", //提交方式
        url : "${base}/foodRelation/addFooRelaction",//路径
       //实体类       自己定义
      data :{"weedId":cycle,"foodMenuId":vegetable,"roomId":home_id,"eachTime":create_id},
      success : function(data){
             $(".tk9").hide(200)
             initChar();
             }
     });
}

//获取房间id
var bas = "${base}"
var home_data=findProject()
//home_data:变量  = zhang.js里边封装的名称(路径,"字典表里边的code")
var home_data = getDataByDicCode(bas,"home")
for(var i=0;i<home_data.length;i++){
$("#home_id").append(
    ' <option value="'+home_data[i].id+'">'+home_data[i].name+'</option>'
)
}

//获取周期
var bas1 = "${base}"
var home_data=findProject()
//home_data:变量  = zhang.js里边封装的名称(路径,"字典表里边的code")
var home_date = getDataByCode(bas1,"LiliMenu")
for(var i=0;i<home_date.length;i++){
$("#cycle").append(
    ' <option value="'+home_date[i].id+'">'+home_date[i].name+'</option>'
)
}


//获取菜品
    $.ajax({
        type : "POST", //提交方式
        url : "${base}/foodRelation/countVariety",//路径
        success : function(data) {//返回数据根据结果进行相应的处理
			 for(var i=0;i<data.length;i++){
             $("#vegetable").append(
                 ' <option value="'+data[i].id+'">'+data[i].vegetable+'</option>'
             )
             }

        }
    });

function findProject(){
 var resultdata;
   $.ajax({
          type:"POST",
          url:"${base}/foodRelation/selectFoodRelation",
          async:false,
            success : function(data){
              resultdata=data;
            }
      });
      return resultdata;
 }
</script>

</body>
</html>